import {HttpHelper} from "./HttpHelper";
import {Injectable} from "@angular/core";
import {Store} from "./domains";

@Injectable()
export class StoreService {
    storeUrl = "stores";
    constructor(private httpHelper:HttpHelper){}
    getStores(name?:string){
        let url = this.storeUrl;
        if (name){
            url = url+`/?name=${name};`
        }
        return this.httpHelper.getJson<Store[]>(url);
    }

    getAbstractStores(name?:string) {
        let url = this.storeUrl+"/all";
        if (name){
            url = url+`/?name=${name};`
        }
        return this.httpHelper.getJson<Store[]>(url);
    }

    getLazyStores(page,size) :Promise<Store[]> {
        let url = this.storeUrl+`/lazy/?page=${page}&size=${size}`;
        return this.httpHelper.getJson<Store[]>(url);
    }
}